<html>
<head><meta charset="utf-8"><title>Lint is not triggered · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html">Lint is not triggered</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242128847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242128847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242128847">(Jun 09 2021 at 20:56)</a>:</h4>
<p>Hi! I've been trying to implement a very very naive lint for <a href="https://github.com/rust-lang/rust-clippy/issues/4629">https://github.com/rust-lang/rust-clippy/issues/4629</a> and it seems my lint is not being used at all in the tests: <a href="https://github.com/pvdrz/rust-clippy/commit/7d762228b26d810cc98b15229b2581a0d5114da9">https://github.com/pvdrz/rust-clippy/commit/7d762228b26d810cc98b15229b2581a0d5114da9</a></p>
<p>The error is not in the logic of the lint itself because the warning is not triggered if I replace the whole <code>check_fn</code> body  by a call to  <code>span_lint_and_help</code> so it must be something I'm missing in the rest of the code but I'm not sure what.</p>
<p>Thanks in advance :)</p>



<a name="242147284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242147284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Takayuki Nakata <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242147284">(Jun 10 2021 at 00:25)</a>:</h4>
<p>It might need to call <code>walk_expr</code> in <code>visit_expr</code> of <code>Visitor</code>.</p>



<a name="242147424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242147424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Takayuki Nakata <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242147424">(Jun 10 2021 at 00:28)</a>:</h4>
<p>I don't read the detail of that issue, but FYI there is <a href="https://rust-lang.github.io/rust-clippy/master/index.html#unused_async">unused_async</a>. This is similar to it.</p>



<a name="242148467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242148467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242148467">(Jun 10 2021 at 00:47)</a>:</h4>
<p>Make sure you have a <code>register_late_pass</code> call</p>



<a name="242148691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242148691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242148691">(Jun 10 2021 at 00:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="316507">Takayuki Nakata</span> <a href="#narrow/stream/257328-clippy/topic/Lint.20is.20not.20triggered/near/242147424">said</a>:</p>
<blockquote>
<p>I don't read the detail of that issue, but FYI there is <a href="https://rust-lang.github.io/rust-clippy/master/index.html#unused_async">unused_async</a>. This is similar to it.</p>
</blockquote>
<p>Oh yes it does the same! my bad</p>



<a name="242148702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242148702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242148702">(Jun 10 2021 at 00:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="360405">Cameron Steffen</span> <a href="#narrow/stream/257328-clippy/topic/Lint.20is.20not.20triggered/near/242148467">said</a>:</p>
<blockquote>
<p>Make sure you have a <code>register_late_pass</code> call</p>
</blockquote>
<p>What do you mean?</p>



<a name="242169957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Lint%20is%20not%20triggered/near/242169957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Lint.20is.20not.20triggered.html#242169957">(Jun 10 2021 at 07:43)</a>:</h4>
<p>Yes, pretty sure, you're missing a <code>register_late_pass</code>. See our documentation here: <a href="https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md#lint-declaration">https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md#lint-declaration</a></p>
<p>TL;DR (but you should read the docs): you have to run <code>cargo dev update_lints</code>, which will add boilerplate and then add a </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">store</span><span class="p">.</span><span class="n">register_early_pass</span><span class="p">(</span><span class="o">||</span><span class="w"> </span><span class="k">box</span><span class="w"> </span><span class="n">unnecessary_async</span>::<span class="n">UnnecessaryAsync</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>in the <code>lib.rs</code> by hand.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>